import tkinter
from functools import partial
from config import BASC

def get_the_input_content(input,inp1,clodoc,main_win,kknum,whether_close=0,title=None):
    cont1=input.get()

    if kknum==0:
        if str(inp1).find(".")!=-1:
            inp12=str(inp1)[:int(str(inp1).rfind("."))]
        else:
            inp12=inp1
        outstr=f"{inp12}{cont1}\n{inp12}"
        clodoc.gloco(outstr)
    else:
        if title is None:
            outstr = f"{inp1}{cont1}"
            clodoc.gloco(outstr)
        else:
            outstr = f"{inp1}{cont1}"
            clodoc.gloco(outstr,title=title)
    if whether_close==0:
        main_win.destroy()

def creat_a_entry_frame(inp1,clodoc,cls=0,kknum=0):
    # def get_frame_program2(beginstr, filename, cls=0, tetype=0):
    if cls==0:
        main_win = tkinter.Tk()
    # .Toplevel()
    else:
        main_win = tkinter.Toplevel()

    # 设置图标ico
    main_win.iconbitmap(f'{BASC}/icon/entry.ico')

    # main_win.geometry("560x800")
    main_win.geometry("356x80")
    # 调整窗口在屏幕上的位置
    # main_win.geometry("+730+156")
    main_win.geometry("+670+370")

    main_win.title(f"目标内容输入框")

    en1=tkinter.Entry(main_win, width=20)
    en1.pack()
    # en1.grid(row=1, column=2, padx=2, pady=2,columnspan=4)

    bt1=tkinter.Button(main_win, text=f"确定", width=6, height=1,
                   # padx=10, pady=10,
                   bg="Wheat", font=("楷书", 11), fg="MediumBlue",
                   # LightCyan，MediumBlue
                   command=partial(get_the_input_content, en1,inp1,clodoc,main_win,kknum))
    bt1.pack()
    # bt1.grid(row=2, column=2, padx=2, pady=2,columnspan=4)

    main_win.mainloop()

if __name__ == '__main__':
    pass